package com.kaguya.proxy;

/**
 * 结构型 静态代理,通过被代理对象和代理对象共同实现同一个接口，代理对象引进被代理对象，对其实现方法进行增强。
 */
public class StaticProxy {

    public static void main(String[] args) {
        HouseOwner houseOwner = new HouseOwner();
        Intermediary intermediary = new Intermediary(houseOwner);
        intermediary.saleHouse();
    }
}

interface HouseSale {
    void saleHouse();
}

class HouseOwner implements HouseSale{

    @Override
    public void saleHouse() {
        System.out.println("saleHouse");
    }
}
class Intermediary implements HouseSale {
    private HouseOwner houseOwner;

    public Intermediary(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    @Override
    public void saleHouse() {
        System.out.println("up house to platForm");
        houseOwner.saleHouse();
        System.out.println("collect tip");
    }
}
